﻿using SF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SF.Ucenter.admin.business
{
    public partial class business_edit : Web.UI.ManagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Model.manager model = (Model.manager)Session[DTKeys.SESSION_ADMIN_INFO];
                if (model != null)
                {
                    ShowBusinessInfo(model);
                }
            }
        }

        private void ShowBusinessInfo(Model.manager bInfo) 
        {
            txtBusinessName.Text = bInfo.real_name;
            txtTelephone.Text = bInfo.telephone;
            txtEMail.Text = bInfo.email;
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            Model.manager model = (Model.manager)Session[DTKeys.SESSION_ADMIN_INFO];
            if (model != null)
            {
                BLL.manager bll = new BLL.manager();
                Model.manager temp_model = bll.GetModel(model.id);
                temp_model.real_name = txtBusinessName.Text;
                temp_model.telephone = txtTelephone.Text;
                temp_model.email = txtEMail.Text;

                if (bll.Update(temp_model) == true)
                {
                    Session[DTKeys.SESSION_ADMIN_INFO] = temp_model;
                    JscriptMsg("商户信息保存成功！", string.Empty);
                }
                else 
                {
                    JscriptMsg("商户信息保存失败，请重新尝试！", string.Empty);
                }
            }
        }
    }
}